from django.shortcuts import render
from django.http import HttpResponse

from .ana import ChipotleAna

from .users_ana import UserAna_obj

# Create your views here.

REMOTE_HOST = "https://pyecharts.github.io/assets/js"

def index(request):

    html = '''\

    
    <h1>XX 同学</h1>

    <hr>

    <h2>Chipotle 数据分析</h2>

    <div align = 'center'>

    <h3>

    <a href = '1/'>每种商品卖出个数</a> <br>

    <a href = '2/'>第个商品卖了多少钱</a><br>

    </h3>

    </div>

    <hr>



    '''

    #return HttpResponse(html)

    context = {}

    return render(request, 'exData/bootcss.html', context)


def index1(request):

    chipo = ChipotleAna()

    bar = chipo.bar_how_many_are_sold_per_item()

    #bar = chipo.echarts_bar(info.index, info.quantity)

    context = dict(
        
        myechart = bar.render_embed(),
        
        host = REMOTE_HOST,
        
        script_list = bar.get_js_dependencies()
    )

    return render(request, 'exData/index.html', context)


def index2(request):

    chipo = ChipotleAna()

    bar = chipo.bar_how_much_are_sold_per_item()

    #bar = chipo.echarts_bar(info.index, info.quantity)

    context = dict(
        
        myechart = bar.render_embed(),
        
        host = REMOTE_HOST,
        
        script_list = bar.get_js_dependencies()
    )

    return render(request, 'exData/index.html', context)

def index3(request):

    print(UserAna_obj.df.head())

    return HttpResponse('OK')


